var WxParse = require('../../wxParse/wxParse.js');
const app = getApp();

Page({
  data: {
    ganzhi: {},

    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    circular: true,

    id: 0,
    goods_detail: {}
  },
  onLoad(options) {
    this.setData({ ganzhi: app.get_ganzhi() });

    this.data.id = parseInt(options.id);
    this.goodsDetail();
  },
  // 商品详情
  goodsDetail() {
    app.ajax('shop/goodsDetail', { id: this.data.id }, res => {
      app.format_img_arr(res.pics);
      this.setData({ goods_detail: res });
      wx.setNavigationBarTitle({ title: res.name });
      app.rich_handle(res.detail, WxParse, this);
    });
  },
  // 去购买页
  to_buy() {
    wx.navigateTo({ url: '/pages/qi-buy/qi-buy?id=' + this.data.id});
  }
});